package com.supermap.guangzhou.weifang.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.supermap.guangzhou.weifang.R;
import com.supermap.guangzhou.weifang.entity.FangWuAnquanXinXi;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PuchaChaxunActivity extends AppCompatActivity {

    @BindView(R.id.btn_back)
    ImageView btnBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.et_dcbbh)
    EditText etDcbbh;
    @BindView(R.id.et_fwbsm)
    EditText etFwbsm;
    @BindView(R.id.et_fwjg)
    EditText etFwjg;
    @BindView(R.id.et_zdmj)
    EditText etZdmj;
    @BindView(R.id.et_jzmj)
    EditText etJzmj;
    @BindView(R.id.et_sjcs)
    EditText etSjcs;
    @BindView(R.id.et_fwdz)
    EditText etFwdz;
    @BindView(R.id.et_mph)
    EditText etMph;
    @BindView(R.id.et_jd)
    EditText etJd;
    @BindView(R.id.tv_fwxz)
    EditText tvFwxz;
    @BindView(R.id.tv_fwcb)
    EditText tvFwcb;
    @BindView(R.id.tv_fwzt)
    EditText tvFwzt;
    @BindView(R.id.tv_jznd)
    EditText tvJznd;
    @BindView(R.id.tv_sfjd)
    EditText tvSfjd;
    @BindView(R.id.tv_aqdj)
    EditText tvAqdj;
    @BindView(R.id.tv_wxqk)
    EditText tvWxqk;
    @BindView(R.id.tv_clyj)
    EditText tvClyj;
    @BindView(R.id.btn_cancel)
    TextView btnCancel;
    @BindView(R.id.btn_confirm)
    TextView btnConfirm;
    public static FangWuAnquanXinXi fangWuAnquanXinXi;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pucha_chaxun);
        ButterKnife.bind(this);
        initToolbar();
        initWindow();
    }

    private void initToolbar() {
        tvTitle.setText("普查查询");
    }

    public void initWindow() {
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        WindowManager windowManager = getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        WindowManager.LayoutParams params = getWindow().getAttributes();
//        params.height = (int) (display.getHeight() * 0.8);
        params.width = (int) (display.getWidth() * 0.8);
        params.alpha = 1.0f;
        getWindow().setAttributes(params);
        getWindow().setGravity(Gravity.CENTER);
    }


    @OnClick({R.id.btn_back, R.id.btn_cancel, R.id.btn_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_back:
                finish();
                break;
            case R.id.btn_cancel:
                finish();
                break;
            case R.id.btn_confirm:
                String dcbbh = etDcbbh.getText().toString();

                String fwbsm = etFwbsm.getText().toString();
                if("".equals(fwbsm)){
                    fwbsm = "0";
                }
                String fwjg = etFwjg.getText().toString();
                String zdmj = etZdmj.getText().toString();
                if("".equals(zdmj)){
                    zdmj = "0";
                }
                String jzmj = etJzmj.getText().toString();
                if("".equals(jzmj)){
                    jzmj = "0";
                }
                String sjcs = etSjcs.getText().toString();
                if("".equals(sjcs)){
                    sjcs = "0";
                }
                String fwdz = etFwdz.getText().toString();
                String mph = etMph.getText().toString();
                String jd = etJd.getText().toString();
                String fwxz = tvFwxz.getText().toString();
                String fwcb = tvFwcb.getText().toString();
                String fwzt = tvFwzt.getText().toString();
                String jznd = tvJznd.getText().toString();
                String sfjd = tvSfjd.getText().toString();
                String aqdj = tvAqdj.getText().toString();
                String wxqk = tvWxqk.getText().toString();
                String clyj = tvClyj.getText().toString();
                FangWuAnquanXinXi fangWuAnquanXinXi = new FangWuAnquanXinXi();
                fangWuAnquanXinXi.setDcbbh(dcbbh);
                fangWuAnquanXinXi.setFwbsm(Integer.parseInt(fwbsm));
                fangWuAnquanXinXi.setFwjg(fwjg);
                fangWuAnquanXinXi.setYzdmj(Double.parseDouble(zdmj));
                fangWuAnquanXinXi.setYjzmj(Double.parseDouble(jzmj));
                fangWuAnquanXinXi.setSjcs(Double.parseDouble(sjcs));
                fangWuAnquanXinXi.setFwdz(fwdz);
                fangWuAnquanXinXi.setMph(mph);
                fangWuAnquanXinXi.setJqmc(jd);
                fangWuAnquanXinXi.setFwxz(fwxz);
                fangWuAnquanXinXi.setFwcb(fwcb);
                fangWuAnquanXinXi.setFwzt(fwzt);
                fangWuAnquanXinXi.setJznd(jznd);
                fangWuAnquanXinXi.setSfjd(sfjd);
                fangWuAnquanXinXi.setAqdj(aqdj);
                fangWuAnquanXinXi.setWxqk(wxqk);
                fangWuAnquanXinXi.setClyj(clyj);
                PuchaChaxunActivity.fangWuAnquanXinXi = fangWuAnquanXinXi;
                finish();
                break;
            default:
                break;
        }
    }
}
